<?php
require_once("/home/bluecbhv/Back-End/Jcuhelpers-WebTech/Content_Scraper/Content_Scraper.php");

require_once("/home/bluecbhv/Back-End/Jcuhelpers-WebTech/Thumbnails/Image_Saver.php");
require_once("/home/bluecbhv/Back-End/Jcuhelpers-WebTech/Thumbnails/Image_Attributes_Setter.php");
require_once("/home/bluecbhv/Back-End/Jcuhelpers-WebTech/Thumbnails/Conversion_Calculator.php");
require_once("/home/bluecbhv/Back-End/Jcuhelpers-WebTech/Thumbnails/Thumbnail_Generator.php");

/***********************************************
	This class would convert an image to a
	thumbnail.
************************************************/
class ImageToThumbnailConverter {
	private $jpegPngOrGifImage = NULL;
	
	private $thumbnailAttributesArray = NULL;
	private $newWidth_N_HeightArray = NULL;
	
	private $image = NULL;
	private $imageWidth = NULL;
	private $imageHeight = NULL;
	private $imageAttributesArray = NULL;

	private $thumbnail = NULL;
	
	/************************************************************/
	
	function __construct($imageLink, $imageFilePath, $thumbnailWidth, $thumbnailHeight) {
		$this->thumbnailAttributesArray = array();
		$this->thumbnailAttributesArray['thumbnailWidth'] = $thumbnailWidth;
		$this->thumbnailAttributesArray['thumbnailHeight'] = $thumbnailHeight;
		
		$csObj = new ContentScraper();
		$this->image = $csObj->scrapeContent($imageLink);
		
		$isObj = new ImageSaver();
		$this->jpegPngOrGifImage = $isObj->saveImage($this->image, $imageFilePath);
		
		$iasObj = new ImageAttributesSetter();
		$this->imageAttributesArray = $iasObj->setImageWidth_Height($this->jpegPngOrGifImage);
		$this->imageWidth = $this->imageAttributesArray['imageWidth'];
		$this->imageHeight = $this->imageAttributesArray['imageHeight'];
		
		$ccObj = new ConversionCalculator($this->imageAttributesArray,
											$this->thumbnailAttributesArray
											);
		$this->newWidth_N_HeightArray = $ccObj->setNewWidth_N_Height();
		
		$this->thumbnail = new ThumbnailGenerator($this->jpegPngOrGifImage, $imageFilePath,
													$this->imageAttributesArray,
													$this->thumbnailAttributesArray,
													$this->newWidth_N_HeightArray
													);
	}
}
?>